package com.imooc;

import com.imooc.bean.Person;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**集合元素的遍历，使用迭代器 Iterator接口
 * @Date:2021/10/8/22:59
 * @Description:
 */
public class TteratorTest {

    @Test
    public void test01(){


        Collection list = new ArrayList(); //有序

        list.add(123);
        list.add(456);
        list.add(new String("Tom"));
        list.add(new Person("Tee",18));

        Iterator iterator = list.iterator();
        while(iterator.hasNext()){
            Object next = iterator.next();
            System.out.println("next = " + next);
        }



    }
}
